package com.dc.server.util;


import java.util.HashMap;
import java.util.Map;

/**
 * 返回数据
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2016年10月27日 下午9:59:27
 */
public class Reponse extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public Reponse() {
        put("code", 0);
        put("msg", "success");
    }


    public static Reponse error(int code, String msg) {
        Reponse reponse = new Reponse();
        reponse.put("code", code);
        reponse.put("msg", msg);
        return reponse;
    }

    public static Reponse ok(String msg) {
        Reponse reponse = new Reponse();
        reponse.put("msg", msg);
        return reponse;
    }

    public static Reponse ok(Map<String, Object> map) {
        Reponse reponse = new Reponse();
        reponse.putAll(map);
        return reponse;
    }

    public static Reponse ok() {
        return new Reponse();
    }

    public Reponse put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public static Map baiDuOk() {
        Map map = new HashMap();
        map.put("retCode", "0");
        return map;
    }

}
